Option Explicit
'
Dim objRec As Object
Dim lngResult As Long
Create a Sub procedure to handle opening the database and creating the Recordset. Add the new routine in Listing 10.21 to the form.
Listing 10.21. Coding the StartProc routine.
Public Sub StartProc()
'
' handle initial startup of form
'
Set objRec = New recObject
'
objRec.DBName = App.Path & "\..\..\data\master.mdb"
objRec.RSName = "StateProvList"
objRec.rsType = rsDynasetType
objRec.RSFocus = "StateProv"
'
objRec.RSOpen Me
objRec.RSEnable Me, False
'
objRec.BtnBarAlign = bbBottom
objRec.BBInit Me
objRec.BBEnable Me, "11111111"
'
End Sub
Listing 10.21 initializes the top-level record object and then sets several properties of the new object before executing the RSOpen and RSEnable methods. Then the routine goes on to initialize and enable the button bar for the form.
Next, you need to add code to the Form_Load event that starts this whole process. Enter the code in Listing 10.22 in the Form_Load event window of the form.
Listing 10.22. Coding the Form_Load routine.
Private Sub Form_Load()
'
' set field tags for data binding
Text1.Tag = "StateProv"
Text2.Tag = "Description"
'